From: Julien Grall Date: Fri, 31 Jan 2014 22:22:45 +0000 (+0000) Subject: xen/arm: Directly return NULL if Xen fails to allocate domain struct X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~5631 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=ea527eda9e1f7a8dcd4cf799c01c4b11468e952f;p=xen.git xen/arm: Directly return NULL if Xen fails to allocate domain struct The current implementation of alloc_domain_struct, dereference the newly allocated pointer even if the allocation has failed. Signed-off-by: Julien Grall Acked-by: Ian Campbell --- diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 635a9a4602..c279a276c8 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -409,8 +409,10 @@ struct domain *alloc_domain_struct(void) struct domain *d; BUILD_BUG_ON(sizeof(*d) > PAGE_SIZE); d = alloc_xenheap_pages(0, 0); - if ( d != NULL ) - clear_page(d); + if ( d == NULL ) + return NULL; + + clear_page(d); d->arch.grant_table_gpfn = xmalloc_array(xen_pfn_t, max_nr_grant_frames); return d; }